package com.cn.qtms.entity;//类注释设置模板

import com.cn.qtms.base.entity.BaseEntity;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.util.List;
import java.util.Set;

/**
 * @Name:TmSysRole
 * @Description:
 * @Author: zhangyang
 * @Date: 2019-11-11 13:00
 **/
@Entity
@Table(name = "tm_sys_role")
@org.hibernate.annotations.Table(appliesTo = "tm_sys_role",comment="角色信息表")
@Getter
@Setter
public class TmSysRole extends BaseEntity {

    @Column(name = "role_code", columnDefinition = "varchar(50) COMMENT '角色代码'", unique = true)
    private String roleCode;

    @Column(name = "role_name", columnDefinition = "varchar(100) COMMENT '角色名称'")
    private String roleName;

    @Column(name = "is_used", columnDefinition = "bit(1) default 0 COMMENT '启用'")
    private Boolean isUsed;

    @JsonIgnore
    @ManyToMany(mappedBy = "tmSysRoles")
    private Set<TmSysUser> tmSysUsers;

    @JsonIgnore
    @ManyToMany(cascade = CascadeType.REFRESH, fetch = FetchType.LAZY)
    @JoinTable(name = "tr_role_resource",
            joinColumns = {@JoinColumn(name = "role_id",
                    referencedColumnName = "id")},
            inverseJoinColumns = {@JoinColumn(name = "resource_id",
                    referencedColumnName = "id")})
    private Set<TmSysResource> tmSysResources;



    @Transient
    private List<String> resources;

    @Override
    public int hashCode() {
        return super.hashCode();
    }

    @Override
    public boolean equals(Object obj) {
        return super.equals(obj);
    }
}
